package com.situ.boot.controller;

import com.situ.boot.entity.User;
import com.situ.boot.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserMapper userMapper;


    //@RequestMapping("/hello.shtml")
    @RequestMapping("/hello")
    @ResponseBody
    public String hello() {
        System.out.println("UserController.hello");
        return  "Hello SprintBoot";
    }

    @RequestMapping("/selectAll")
    @ResponseBody
    public List<User> selectAll() {
        List<User> list = userMapper.selectAll();
        return  list;
    }

    @RequestMapping("/getUserListPage")
    public String getUserListPage(Model model) {
        List<User> list = userMapper.selectAll();
        model.addAttribute("list", list);
        // return "/WEB-INF/jsp/user_list.jsp";
        return "user_list";
    }
}
